package models;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Version;

import com.avaje.ebean.Expr;
import com.avaje.ebean.ExpressionList;

import play.db.ebean.Model;

@Entity
@Table(name="doctor_topics_for_referral")
public class DoctorsReferralTemplates extends Model{
	
	public static final long serialVersionUID = 1L;

	@Id
	@Column(name="iddoctor_topics_for_referral")
	public long id;
	
	@OneToOne
	@JoinColumn(name="doctor_user_id")
    public User doctor;
	
	@Column(name="topic_name")
    public String topicName;
    
	@Column(name="file_name")
    public String fileName;
	
	@Column(name="s3_file_name")
    public String S3fileName;

	
	
	@Column(name="file_type")
    public String fileType;
	
	@Column(name="file_size")
    public Long fileSize;
	

    
    
    public static Model.Finder<Long,DoctorsReferralTemplates> find = new Model.Finder(Long.class, DoctorsReferralTemplates.class);
    public static List<DoctorsReferralTemplates> getDoctorsTemplates(Long userId){
        
    	List<DoctorsReferralTemplates> templates =find
    												.where().eq("doctor_user_id",userId)
    												.findList();
    	return templates;
    }

    public static DoctorsReferralTemplates getTemplateDetails(Long templateId){
        
    	DoctorsReferralTemplates templates =find
    												.where().eq("iddoctor_topics_for_referral",templateId)
    												.findUnique();
    	return templates;
    }
}